using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework;
using Xyne.Utilities;
using Xyne.Events;
using Xyne.Actions;

namespace Xyne.Network
{
    public class DebugComponent : NetworkComponent
    {
        public DebugComponent(Game game)
            : base(game)
        {
            Wizard = GameObjects.LeftWizard;


            if (Session == null)
            {
                Session = NetworkSession.Create(ConnectionType, 1, 2);
                Session.AllowHostMigration = false;
                Session.AllowJoinInProgress = false;
                if (Session.LocalGamers.Count > 0)
                    Gamer = Session.LocalGamers[0];

                Session.StartGame();
            }
        }

        /// <summary>
        /// The bottleneck where all network-based events go (i.e. game ending)
        /// </summary>
        /// <param name="e">The event</param>
        public override void HandleEvent(Event e)
        {
            EventManager.Instance.SendEvent(e);
        }

        /// <summary>
        /// The bottleneck where all network-based actions go (i.e. game fireball)
        /// </summary>
        /// <param name="e">The action</param>
        public override void HandleAction(Action a)
        {
            ActionManager.Instance.ActionActivated(a);
        }
    }
}
